package com.xch.service;

import com.xch.bean.Courier;
import com.xch.dao.BaseCourierDao;
import com.xch.dao.impl.CourierDaoMysql;
import com.xch.exception.DuplicateCodeException;

import java.util.List;

public class CourierService {
    private static BaseCourierDao dao = new CourierDaoMysql();

    public static List<Courier> findAll(boolean limit,int offset,int pageNumber){
        return dao.findAll(limit, offset, pageNumber);
    }
    public static int total(){
        return dao.total();
    }

    public static Courier findByPhone(String courierPhone){
        return dao.findByPhone(courierPhone);
    }

    public static boolean insert(Courier c){
        try {
            boolean flag = dao.insert(c);
            return flag;
        } catch (DuplicateCodeException e) {
            e.printStackTrace();
        }
        return false;
    }

    public static boolean update(int id,Courier c){
        return dao.update(id,c);
    }

    public static boolean delete(int id){
        return dao.delete(id);
    }
}
